package com.letoken.platform.repo.app.manager;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.letoken.platform.repo.app.dao.AppUserRechargeMapper;
import com.letoken.platform.repo.app.po.AppUserRecharge;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * @author letokenlabs
 * @date 2022/11/18$
 */
@Log4j2
@Repository
public class AppUserRechargeManager {

    @Autowired
    private AppUserRechargeMapper appUserRechargeMapper;


    /**
     * 根据交易hash查询充值记录
     *
     * @param txHash
     * @param netType
     * @return
     */
    public AppUserRecharge queryByhash(String txHash, String netType) {
        QueryWrapper<AppUserRecharge> query = new QueryWrapper<>();
        query.eq("txid", txHash).eq("net_typ", netType);
        return appUserRechargeMapper.selectOne(query);
    }


    /**
     * 插入充值hash日志
     *
     * @param appUserRecharge
     * @return
     */
    public Integer add(AppUserRecharge appUserRecharge) {
        return appUserRechargeMapper.insert(appUserRecharge);
    }

    public Integer update(AppUserRecharge appUserRecharge) {
        return appUserRechargeMapper.updateById(appUserRecharge);
    }

    public int updateErrorResponse(String hash, String response){
        return  appUserRechargeMapper.updateErrorResponse(hash, response);
    }
}
